package cn.edu.zbu.servlet;

import cn.edu.zbu.cn.edu.zbu.dao.CarDao;
import cn.edu.zbu.cn.edu.zbu.dao.CarDao;
import cn.edu.zbu.cn.edu.zbu.dao.CarDaoImpl;
import cn.edu.zbu.pojo.Car;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "DeleteServlet", value = "/DeleteServlet")
public class DeleteServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String idString=request.getParameter("id");
        int id=Integer.parseInt(idString);
        CarDao dao=new CarDaoImpl();
        dao.delete(id);
        response.sendRedirect(request.getContextPath()+"/index.jsp");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }
}
